#include "main/utils.h"
using namespace std;

class Solution {
  public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
      unordered_map<string, vector<string>> mp;
      for (auto& s : strs) {
        string key = s;
        sort(key.begin(), key.end());
        mp[key].emplace_back(s);
      }
      vector<vector<string>> ret;
      for (auto iter = mp.begin(); iter != mp.end(); ++iter) {
        ret.emplace_back(iter->second);
      }
      return ret;
    }
};

int main() {
  vector<string> input = {"eat", "tea", "tan", "ate", "nat", "bat"};
  Solution su;
  auto output = su.groupAnagrams(input);
  printVec("output", output);
}
